/*
 * Copyright (c) 2013, SRI International
 * All rights reserved.
 * Licensed under the The BSD 3-Clause License;
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 * 
 * http://opensource.org/licenses/BSD-3-Clause
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 
 * Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 * 
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * 
 * Neither the name of the aic-web-praise nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package com.sri.ai.lpitools.cobra.server.servers.api;

import org.apache.xmlrpc.XmlRpcException;

import com.sri.ai.lpitools.cobra.gwtutil.dataobjects.shared.LWPException;


/**
 * An interface that defines the base methods that a remote server probably needs.
 * Most servers will have extra methods that perform setup,
   but it is assumed this will be handled on a case by case basis.
 * Implementations of this interface are intended to have a corresponding
   implementation of the COBRA interface to communicate with.
 * @author dabraham
 *
 */
public interface COBRAServer {
	
	
	/**
	 * Returns a list of users
	 * @return
	 */
	public String getUsers() throws LWPException;
	
	/**
	 * A method to authenticate a user.
	 * @param user The user's name.
	 * @param password The user's password.
	 * @return True if valid user/pass combo, false if not.
	 */
	public String authenticateUser(String user) throws LWPException;
	
	/**
	 * Returns true if user was add to user list
	 * @param user
	 * @return
	 */
	public boolean saveUser(String user) throws LWPException;
	
	/**
	 * Returns true if user was deleted from user list
	 * @param user
	 * @return
	 */
	public boolean deleteUser(String user) throws LWPException;
	
	/**
	 * Gets a list of the names of user's models.
	 * @param user The user's name.
	 * @return The list of the user's model names.
	 */
	public String listModels(String user) throws LWPException;
	
	/**
	 * 
	 * @param user
	 * @param modelTitle
	 * @return
	 */
	public String getModelByName(String user, String modelTitle) throws LWPException;
	
	/**
	 * Returns a list of the user's saved queries 
	 * @param user The user of the system.
	 * @return The list of saved queries.
	 */
	public String listQueries(String user) throws LWPException;
	
	/**
	 * 
	 * @param user
	 * @return
	 */
	public String listEvidences(String user) throws LWPException;
	
	/**
	 * 
	 * @param user
	 * @param queryTitle
	 * @return
	 */
	public String getQuery(String user, String queryTitle) throws LWPException;
	
	/**
	 * 
	 * @param user
	 * @param evidencesTitle
	 * @return
	 */
	public String getEvidence(String user, String evidencesTitle) throws LWPException;

	/**
	 * Saves the whole model, body and info
	 * @param user
	 * @param modelTitle
	 * @param model
	 * @return
	 */
	public boolean saveModel(String user, String title, String model) throws LWPException;

	/**
	 * Only saves the info part of the model
	 * @param user
	 * @param modelTitle
	 * @param model
	 * @return
	 */
	public boolean saveModelInfo(String user, String title, String model) throws LWPException;	

	/**
	 * Only saves the body of the model
	 * @param user
	 * @param modelTitle
	 * @param model
	 * @return
	 */
	public boolean saveModelBody(String user, String title, String model) throws LWPException;	
	
	/**
	 * 
	 * @param user
	 * @param queryTitle
	 * @param query
	 * @return
	 */
	public boolean saveQuery(String user, String title, String query) throws LWPException;
	
	/**
	 * 
	 * @param user
	 * @param modelTitle
	 * @return
	 */
	public boolean deleteModel(String user, String modelTitle) throws LWPException;
	

	/**
	 * 
	 * @param user
	 * @param queryTitle
	 * @return
	 */
	public boolean deleteQuery(String user, String queryTitle) throws LWPException;

	/**
	 * 
	 * @param user
	 * @param evidencesTitle
	 * @param evidences
	 * @return
	 */
	public boolean saveEvidences(String user, String title, String evidences) throws LWPException;
	
	/**
	 * 
	 * @param user
	 * @param evidencesTitle
	 * @return
	 */
	public boolean deleteEvidences(String user, String evidencesTitle) throws LWPException;

	/**
	 * Function to close the backend data storage and do clean up on it
	 * @throws XmlRpcException 
	 */
	public void close() throws LWPException;
	

}
